<?php

namespace app\http\service;

use think\worker\Server;

class Worker extends Server
{
  protected $socket = 'websocket://0.0.0.0:2346';  //'http://0.0.0.0:2346';

  public function onWorkerStart($worker)
  {
      
      
  }
  public function onWorkerReload($worker)
  {
      
      
  }
  public function onConnect($connection)
  {
      
      
  }
  public function onMessage($connection, $data)
  {
         // 向浏览器发送hello world
    $connection->send('hello world');
    //$connection->send(json_encode($data));
  
      
  }
  public function onClose($connection)
  {
      
  }
  public function onError($connection, $code, $msg)
  {
      
    echo "error [ $code ] $msg\n";
  
      
  }
}
